package catalog.clientsample;

import java.util.List;
import java.util.Random;

import catalog.Catalog;
import catalog.CatalogService;
import catalog.Item;

public class ClientSample {

	public static void main(String[] args) {
        System.out.println("***********************");
        System.out.println("Create Web Service Client...");
        CatalogService service1 = new CatalogService();
        System.out.println("Create Web Service...");
        Catalog catal = service1.getCatalogPort();
        System.out.println("Call Web Service Operation...");
        int n=new Random().nextInt(100);
       
        Item i1= catal.create();
		i1.setName("foobar"+n);
		i1.setDescription("foobar"+n);
		i1.setPrice(100.50);
		catal.save(i1);
		Item i2= catal.create();
		i2.setName("barfoo"+n);
		i2.setDescription("barfoo"+n);
		i2.setPrice(200.50);
		catal.save(i2);
		Item i3= catal.create();
		i3.setName("barbaz"+n);
		i3.setDescription("barbaz"+n);
		i3.setPrice(300.50);
		catal.save(i3);
		Item i4= catal.create();
		i4.setName("zoobar"+n);
		i4.setDescription("zoobar"+n);
		i4.setPrice(400.50);
		catal.save(i4);
		
		List<Item> items = catal.getItems(1,100);
		if (items != null) {
			for (Item item : items) {
				System.out.println("item " + item.getName());
				
			}
		} else {
			System.out.println("Aucun item");
		}		

        
       

        System.out.println("***********************");
        System.out.println("Call Over!");
	}
}
